<?php 

$email=$_POST['email'];

$preg = "/^[A-z0-9]\w*@[A-z0-9-]+\.[A-z]{2,}(\.[A-z]{2,})*$/";

$c = preg_match($preg , $email);

if(!$c){
	$arr=array(
			'error'=>1,
			'mail'=>'邮件不合法',
		);
		echo json_encode($arr);exit;
}

$emails=include_once './user.php';

// var_dump($emails);
foreach ($emails as $v) {
	if($v['email']==$email){
		$arr=array(
				'error'=>1,
				'mail'=>'邮件已经存在'
			);
		echo json_encode($arr);exit;
	}
}


$arr=array(
			'error'=>0,
			'mail'=>'邮件合法',
		);
		echo json_encode($arr);



 ?>